

import { LoopList } from '../Script/LoopListCell';
import { IData } from './TestShowNode';
const { ccclass, property } = cc._decorator;

@ccclass
export class TestLoop extends cc.Component {
    /**分层渲染节点 */
    @property(cc.Node)
    public rendeLayer: cc.Node = null;
    /**显示节点预制件 */
    @property(cc.ScrollView)
    public scrollView: cc.ScrollView = null;
    /**显示节点预制件 */
    @property(cc.Prefab)
    public showPrefab: cc.Prefab = null;

    start() {
        let data: IData[] = [];
        for (let i = 0, len = 30; i < len; ++i) {
            data.push({ index: i, text: "内容" + i, size: cc.size(i % 2 == 0 ? 750 : 600, i % 2 == 0 ? 100 : 150) });
        }
        console.warn(this.rendeLayer)
        LoopList.ins<IData>("Test").init(this.scrollView, this.rendeLayer);
        LoopList.ins<IData>("Test").initData(data, this.showPrefab, cc.size(750, 100), cc.v2(0.5, 1));

        this.scheduleOnce(() => {
            LoopList.ins<IData>("Test").pushDatas([
                { index: 1, text: "我是压入1", size: cc.size(600, 150) },
                { index: 2, text: "我是压入2", size: cc.size(600, 150) },
                { index: 3, text: "我是压入3", size: cc.size(600, 150) },
            ]);
        }, 3)
    }
}


